package com.ymatou.iapi.trading.sellerquery2.testcase;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.stream.Collectors;

import org.json.JSONArray;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.iapi.trading.operate.parameter.OrderGroupVo;
import com.ymatou.iapi.trading.operate.parameter.OrderItemVo;
import com.ymatou.iapi.trading.operate.parameter.OrderVo;
import com.ymatou.iapi.trading.operate.parameter.PlaceOrderService;
import com.ymatou.iapi.trading.operate.parameter.enums.AppTerminalSourceEnum;
import com.ymatou.iapi.trading.operate.parameter.enums.LogisticsTypeEnum;
import com.ymatou.iapi.trading.operate.parameter.enums.OrderTypeEnum;
import com.ymatou.iapi.trading.operate.parameter.enums.PriceTypeEnum;
import com.ymatou.iapi.trading.operate.parameter.enums.ProductRefundChannelEnum;
import com.ymatou.iapi.trading.operate.parameter.enums.SalesTypeEnum;
import com.ymatou.iapi.trading.operate.parameter.enums.TerminalSourceEnum;
import com.ymatou.iapi.trading.operate.parameter.req.PlaceOrderReq;
import com.ymatou.iapi.trading.operate.service.PlaceOrderCall;
import com.ymatou.iapi.trading.ordersync.service.SyncVerifyService;
import com.ymatou.iapi.trading.sellerquery.parameter.resp.GetRelatedOrderInfosResp;
import com.ymatou.iapi.trading.sellerquery2.parameter.GetRelatedOrderInfosBean;
import com.ymatou.query.seller.trading.api.parameter.Ymt_Order;
import com.ymatou.query.seller.trading.api.parameter.Ymt_OrderInfo;
import com.ymatou.query.seller.trading.api.service.OrderCreate;
import com.ymatou.query.trading.api.parameter.OrderConverter;
import com.ymt.core.tool.FormatUtil;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.TestCase;
import com.ymt.utils.annotation.TestSuite;
import com.ymt.utils.tag.P1;
import com.ymt.utils.tag.P3;
import com.ymttest.database.model.OrderInfoForRelated;
import com.ymttest.database.model.OrderItemInfoForRelated;
import com.ymttest.database.sqlwapper.DefaultWapper;
import com.ymttest.utils.DataUtil;
import com.ymttest.utils.EnvSetup;
import com.ymttest.utils.TestDataManager;
import com.ymttest.utils.constant.ECode;

/**
 * 获取相关订单详情Call FreeMaker Template自动生成代码
 */
@SuppressWarnings("rawtypes")
@TestSuite
public class Ts_GetRelatedOrderInfos {

	private static GetRelatedOrderInfosBean groisBean;
	//	private static com.ymatou.query.seller.trading.api.service.GetRelatedOrderInfosCall groisCall;
	private static com.ymatou.iapi.trading.sellerquery2.service.GetRelatedOrderInfosCall groisCall;
	private List<Ymt_Order> orders;
	private List<Ymt_OrderInfo> orderInfos;

	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("获取相关订单详情");
	}

	@Before
	public void caseUp() {
		groisBean = new GetRelatedOrderInfosBean();
		//		groisCall = new com.ymatou.query.seller.trading.api.service.GetRelatedOrderInfosCall();
		groisCall = new com.ymatou.iapi.trading.sellerquery2.service.GetRelatedOrderInfosCall();
		orders = new ArrayList<Ymt_Order>();
		orderInfos = new ArrayList<Ymt_OrderInfo>();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(groisCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}

	private void verify() {
		GetRelatedOrderInfosResp expectResponse = new GetRelatedOrderInfosResp();
		ConstructExpectedResponse(expectResponse);
		GetRelatedOrderInfosResp actualResponse = groisCall
				.getRelatedOrderInfosResp();
		List<OrderInfoForRelated> expects = expectResponse.getOrderInfoList();
		List<OrderInfoForRelated> actuals = actualResponse.getOrderInfoList();
		if (expects == null) {
			DataUtil.verify(expects, actuals, "验证OrderInfoList == null");
		} else {
			boolean sameSize = expects.size() == actuals.size();
			DataUtil.verify(expects.size(), actuals.size(),
					"验证OrderInfoList.size()");
			if (sameSize) {
				for (int i = 0; i < expects.size(); i++) {
					OrderInfoForRelated expect = expects.get(i);
					OrderInfoForRelated actual = actuals.get(i);
					verifyOrderInfoForRelated(expect, actual);
				}
			}
		}
	}

	private void verifyOrderInfoForRelated(OrderInfoForRelated expect,
			OrderInfoForRelated actual) {
		DataUtil.verify(expect.getOrderId(), actual.getOrderId(), "验证OrderId");
		DataUtil.verify(expect.getTradingStatus(), actual.getTradingStatus(),
				"验证TradingStatus");
		DataUtil.verify(expect.getUserId(), actual.getUserId(), "验证UserId");
		DataUtil.verify(expect.getBuyerId(), actual.getBuyerId(), "验证BuyerId");
		DataUtil.verify(expect.getBuyerLoginId(), actual.getBuyerLoginId(),
				"验证BuyerLoginId");
		DataUtil.verify(expect.getSellerLoginId(), actual.getSellerLoginId(),
				"验证SellerLoginId");
		DataUtil.verify(expect.getPayableAmount(), actual.getPayableAmount(),
				"验证PayableAmount");
		DataUtil.verify(expect.getYmtCouponCode(), actual.getYmtCouponCode(),
				"验证YmtCouponCode");
		DataUtil.verify(expect.getYmtCouponAmount(),
				actual.getYmtCouponAmount(), "验证YmtCouponAmount");
		DataUtil.verify(expect.getSellerCouponCode(),
				actual.getSellerCouponCode(), "验证SellerCouponCode");
		DataUtil.verify(expect.getSellerCouponAmount(),
				actual.getSellerCouponAmount(), "验证SellerCouponAmount");
		DataUtil.verify(expect.getMainOrderId(), actual.getMainOrderId(),
				"验证MainOrderId");
		DataUtil.verify(expect.getPromotionReducedAmount(),
				actual.getPromotionReducedAmount(), "验证PromotionReducedAmount");
		List<OrderItemInfoForRelated> exps = expect.getOrderItemInfoList();
		List<OrderItemInfoForRelated> acts = actual.getOrderItemInfoList();
		if (exps == null) {
			DataUtil.verify(exps, acts, "验证OrderItemInfoList == null");
		} else {
			boolean sameSize = exps.size() == acts.size();
			DataUtil.verify(exps.size(), acts.size(),
					"验证OrderItemInfoList.size()");
			if (sameSize) {
				/*				for (OrderItemInfoForRelated exp : exps) {
									DataUtil.verify(true, exist, "验证OrderItemInfoList中是否存在\n"
											+ exp.toString() + "\n的记录");				
									
									boolean exist = acts.stream().anyMatch(
											x -> x.toString().equals(exp.toString()));
									DataUtil.verify(true, exist, "验证OrderItemInfoList中是否存在\n"
											+ exp.toString() + "\n的记录");
								}*/
				for (int i = 0; i < exps.size(); i++) {

					DataUtil.verify(exps.get(i).getTitle(), acts.get(i)
							.getTitle(), "title");
					DataUtil.verify(exps.get(i).getProductId(), acts.get(i)
							.getProductId(), "productId");
					DataUtil.verify(exps.get(i).getCatalogId(), acts.get(i)
							.getCatalogId(), "catalogId");
					DataUtil.verify(exps.get(i).getAmount(), acts.get(i)
							.getAmount(), "amount");
					DataUtil.verify(exps.get(i).getProductPrice(), acts.get(i)
							.getProductPrice(), "productPrice");
					DataUtil.verify(exps.get(i).getSellerCouponAmount(), acts
							.get(i).getSellerCouponAmount(),
							"sellerCouponAmount");
					DataUtil.verify(exps.get(i).getYmtCouponAmount(),
							acts.get(i).getYmtCouponAmount(), "ymtCouponAmount");
					DataUtil.verify(exps.get(i).getDiscount(), acts.get(i)
							.getDiscount(), "discount");
					DataUtil.verify(exps.get(i).getTitle(), acts.get(i)
							.getTitle(), "discount");
					DataUtil.verify(exps.get(i).getFreight(), acts.get(i)
							.getFreight(), "freight");
					if (exps.get(i).getPromotion() != null) {
						DataUtil.verify(exps.get(i).getPromotion().getID(),
								acts.get(i).getPromotion().getID(),
								"promotion id");

						DataUtil.verify(exps.get(i).getPromotion().getType(),
								acts.get(i).getPromotion().getType(),
								"promotion type");

						DataUtil.verify(exps.get(i).getPromotion().getName(),
								acts.get(i).getPromotion().getName(),
								"promotion name");

						DataUtil.verify(exps.get(i).getPromotion()
								.getCondition(), acts.get(i).getPromotion()
								.getCondition(), "promotion condition");

						DataUtil.verify(
								exps.get(i).getPromotion().getContent(), acts
										.get(i).getPromotion().getContent(),
								"promotion content");

						DataUtil.verify(exps.get(i).getPromotion()
								.getReducedAmount(), acts.get(i).getPromotion()
								.getReducedAmount(), "promotion reducedAmount");

						DataUtil.verify(exps.get(i).getPromotion()
								.getPartialReducedAmount(), acts.get(i)
								.getPromotion().getPartialReducedAmount(),
								"promotion partialReducedAmount");
					}
				}

			}

		}
	}
	private void ConstructExpectedResponse(GetRelatedOrderInfosResp response) {
		execute(groisBean.getOrderId());
		List<OrderInfoForRelated> orderInfoList = new ArrayList<>();
		OrderInfoForRelated r = null;
		if (!DataUtil.isNullOrEmpty(orders)) {
			for (Ymt_Order order : orders) {
				r = new OrderInfoForRelated();
				r.setBuyerId(order.getiBuyerId());
				r.setBuyerLoginId(order.getsBuyerLoginId());
				r.setMainOrderId((long) order.getiMainOrderId());
				r.setOrderId(order.getiOrderId());
				r.setPayableAmount(order.getfPayableAmount());
				r.setPromotionReducedAmount(order.getfSellerPromotionAmount());
				r.setSellerCouponAmount(order.getfSellerCouponAmount());
				r.setSellerCouponCode(order.getsSellerCouponCode());
				r.setSellerLoginId(order.getsSellerLoginId());
				r.setTradingStatus(order.getiTradingStatus());
				r.setUserId(order.getiUserId());
				r.setYmtCouponAmount(order.getfYmtCouponAmount());
				r.setYmtCouponCode(order.getsYmtCouponCode());
				List<OrderItemInfoForRelated> orderItemInfoList = new ArrayList<OrderItemInfoForRelated>();
				List<Ymt_OrderInfo> matchs = orderInfos.stream()
						.filter(x -> x.getiOrderId() == order.getiOrderId())
						.collect(Collectors.toList());
				if (!DataUtil.isNullOrEmpty(matchs)) {
					for (Ymt_OrderInfo o : matchs) {
						OrderItemInfoForRelated ir = new OrderItemInfoForRelated();
						ir.setAmount(o.getiAmount());
						ir.setCatalogId(o.getsCatalogId());
						ir.setDiscount(o.getfDiscount());
						ir.setFreight(o.getfFreight());
						ir.setProductId(o.getsProductId());
						ir.setProductPrice(o.getfProductPrice());
						ir.setPromotion(OrderConverter.GetPromotion(o));
						ir.setSellerCouponAmount(o.getfSellerCouponAmount());
						ir.setSupportRtnWithoutReason(o
								.isbSupportRtnWithoutReason());
						ir.setTitle(o.getsTitle());
						ir.setYmtCouponAmount(o.getfYmtCouponAmount());
						orderItemInfoList.add(ir);
					}
				}
				r.setOrderItemInfoList(orderItemInfoList);
				orderInfoList.add(r);
			}
		}
		response.setOrderInfoList(orderInfoList);
	}

	private void execute(int orderId) {
		DefaultWapper db = new DefaultWapper();
		List<Map> list1 = db.executeSql(getSql1(orderId));
		List<Map> list2 = db.executeSql(getSql2(orderId));
		convertResult(list1, list2);
	}

	private void convertResult(List<Map> list1, List<Map> list2) {
		if (false == DataUtil.isNullOrEmpty(list1)) {
			for (Map m : list1) {
				Ymt_Order o = new Ymt_Order();
				DataUtil.mapToBean(o, m);
				orders.add(o);
			}
		}
		if (false == DataUtil.isNullOrEmpty(list2)) {
			for (Map m : list2) {
				Ymt_OrderInfo o = new Ymt_OrderInfo();
				DataUtil.mapToBean(o, m);
				orderInfos.add(o);
			}
		}
	}

	private String baseSql(int orderId) {
		return "DECLARE @MainOrderId INT;"
				+ " DECLARE @OrdersTable TABLE(iOrderId INT NOT NULL);"
				+ " SELECT @MainOrderId = iMainOrderId FROM Ymt_Orders ( NOLOCK ) WHERE iOrderId = "
				+ orderId
				+ ";"
				+ " INSERT INTO @OrdersTable SELECT iOrderid FROM Ymt_Orders ( NOLOCK ) WHERE iMainOrderId = @MainOrderId;";
	}

	private String getSql1(int orderId) {
		String sql1 = "SELECT a.iOrderId, a.iTradingStatus, a.iUserId, a.iBuyerId, a.sBuyerLoginId,"
				+ " a.sSellerLoginId, a.fPayableAmount, a.sYmtCouponCode, a.fYmtCouponAmount,"
				+ " a.sSellerCouponCode, a.fSellerCouponAmount, a.iMainOrderId, a.fSellerPromotionAmount"
				+ " FROM Ymt_Orders a ( NOLOCK )"
				+ "   JOIN @OrdersTable b ON a.iOrderId = b.iOrderId order by a.iOrderId asc;";
		return baseSql(orderId) + sql1;
	}

	private String getSql2(int orderId) {
		String sql2 = "SELECT a.iOrderId, a.sProductId, a.sCatalogId, a.sTitle,"
				+ " a.iAmount, a.fYmtCouponAmount, a.fSellerCouponAmount, a.fFreight,"
				+ " a.fDiscount, a.fProductPrice, a.fSellerPromotionAmount, a.bSupportRtnWithoutReason"
				+ " , c.promotionId,c.promotionName,c.promotionType,"
				+ " c.matchCondition,c.promotionValue,c.reducedAmount"
				+ " FROM Ymt_OrderInfo a ( NOLOCK )"
				+ " JOIN @OrdersTable b ON a.iOrderId = b.iOrderId"
				+ " LEFT JOIN Ymt_SellerPromotion(nolock) c on c.OrderInfoId = a.sOrderInfoId";
		return baseSql(orderId) + sql2;
	}

	/**	 创建2个买手多个订单，使用平台优惠券,商家券
	 * 	
	*/
	private Map placeOrder3() {
		Map map = new HashMap();
		try {
			PlaceOrderReq placeorderBean = new PlaceOrderReq();
			PlaceOrderCall placeorderCall = new PlaceOrderCall();
			int userId = Integer.valueOf(EnvSetup.getData("BuyUserId"));
			int sellerId = Integer.valueOf(EnvSetup.getData("SellerId"));

			String productName = "auto自动化测试";
			String pic = "http://p243.img.ymatou.com:10243/upload/productdes/3afa103d4ec4466f824b9f0458d6f4e2.jpg";
			BigDecimal price = new BigDecimal(130);
			String productId = "auto123456";

			placeorderBean.setAppId("AutoTest");
			// placeorderBean.setYmatouCoupon(ymtCoupon);
			placeorderBean.setUserId(userId);
			placeorderBean.setRequestId(TestDataManager.getRandomUUID()
					.toString());
			placeorderBean.setTerminalSource(TerminalSourceEnum.IOS);
			placeorderBean.setAppTerminalSource(AppTerminalSourceEnum.Phone);
			OrderGroupVo groupVo1 = new OrderGroupVo();

			groupVo1.setSellerId(sellerId);
			List<OrderVo> orders = new ArrayList<OrderVo>();
			OrderVo ordervo1 = new OrderVo();
			ordervo1.setAutoCancelOrderHours(new BigDecimal(1));
			ordervo1.setOrderType(OrderTypeEnum.Spot);
			ordervo1.setPaidFull(true);

			List<OrderItemVo> items = new ArrayList<OrderItemVo>();
			OrderItemVo orderitem1 = new OrderItemVo();
			orderitem1.setProductNum(1);
			orderitem1.setProductName(productName);
			orderitem1.setPriceType(PriceTypeEnum.VipPrice);
			orderitem1.setProductId(productId);
			orderitem1.setCatalogId(TestDataManager.getRandomUUID().toString());
			price = new BigDecimal(210);
			orderitem1.setEarnestPrice(price);
			orderitem1.setProductPrice(price);
			orderitem1.setOriginalPrice(price);
			orderitem1.setSalesType(SalesTypeEnum.AlreadyInStock);
			orderitem1.setLogisticsType(LogisticsTypeEnum.SailProtect);
			orderitem1
					.setProductRefundChannel(ProductRefundChannelEnum.Official);
			orderitem1.setFirstCategoryId(111111111);
			orderitem1.setSecondCategoryId(22222222);
			orderitem1.setThirdCategoryId(3333333);
			items.add(orderitem1);
			ordervo1.setOrderItems(items);
			ordervo1.setFreight(new BigDecimal("71"));

			// 第二个订单
			orders.add(ordervo1);
			orders.add(ordervo1);
			groupVo1.setOrders(orders);

			// 买手2
			OrderGroupVo groupVo2 = new OrderGroupVo();

			// 卖家2
			int sellerId2 = 2830;
			groupVo2.setSellerId(sellerId2);
			List<OrderVo> sellerId2orders1 = new ArrayList<OrderVo>();
			OrderVo sellerId2order1 = new OrderVo();
			sellerId2order1.setAutoCancelOrderHours(new BigDecimal(1));
			sellerId2order1.setOrderType(OrderTypeEnum.Spot);
			sellerId2order1.setPaidFull(true);
			// 定义买手下订单列表
			List<OrderItemVo> sellerId2Items1 = new ArrayList<OrderItemVo>();
			// 订单1
			OrderItemVo sellerId2Item1 = new OrderItemVo();

			String catalogId2 = TestDataManager.getRandomUUID().toString();
			sellerId2Item1.setCatalogId(TestDataManager.getRandomUUID()
					.toString());
			// 商品数量
			int productNum2 = 1 + new Random().nextInt(5);
			sellerId2Item1.setProductNum(productNum2);
			sellerId2Item1.setProductName(productName);
			sellerId2Item1.setPriceType(PriceTypeEnum.VipPrice);
			sellerId2Item1.setProductId(productId);
			BigDecimal price2 = new BigDecimal(370);
			sellerId2Item1.setEarnestPrice(price2);
			sellerId2Item1.setFirstCategoryId(111111111);
			sellerId2Item1.setSecondCategoryId(22222222);
			sellerId2Item1.setThirdCategoryId(3333333);
			sellerId2Item1.setProductPrice(price2);
			sellerId2Item1.setOriginalPrice(price2);
			sellerId2Item1.setSalesType(SalesTypeEnum.AlreadyInStock);
			sellerId2Item1.setLogisticsType(LogisticsTypeEnum.SailProtect);
			sellerId2Item1
					.setProductRefundChannel(ProductRefundChannelEnum.Official);
			sellerId2Items1.add(sellerId2Item1);
			sellerId2order1.setOrderItems(sellerId2Items1);
			sellerId2order1.setFreight(new BigDecimal("45"));
			sellerId2orders1.add(sellerId2order1);
			groupVo2.setOrders(sellerId2orders1);

			List<OrderGroupVo> orderGroupVos = new ArrayList<OrderGroupVo>();
			orderGroupVos.add(groupVo1);
			orderGroupVos.add(groupVo2);

			placeorderBean.setOrderGroups(orderGroupVos);
			placeorderCall.setData(placeorderBean);
			placeorderCall.callService();

			map.put("orderId", placeorderCall.getOrderIds());
			map.put("tradingId", placeorderCall.getTradingId());

		} catch (Exception e) {
			Logger.fail(e);
		}
		return map;
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetRelatedOrderInfos_001() {
		Logger.start(true, "订单包含多个商品, 根据OrderId获取相关订单详情,成功");
		try {
			Logger.comment("准备测试订单数据");
			int sellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
			int userId = Integer.valueOf(EnvSetup.getData("BuyUserId"));
			OrderCreate o = new OrderCreate();
			o.setProductCount(3);
			int orderId = o.create1_M2cOrder(userId, sellerId).getiOrderId();
			Thread.sleep(500l);
			Logger.comment("准备测试订单数据完成");

			groisBean.setOrderId(orderId);
			String s = FormatUtil.beanToHttpString(groisBean, true, false);
			groisCall.setData(s);
			groisCall.callService();
			Logger.verifyEquals(ECode.SUCCESS, groisCall.getCode(), "验证Code");
			verify();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_GetRelatedOrderInfos_002() {
		Logger.start(false, "OrderId为空，获取相关订单详情,失败");
		try {
			String s = FormatUtil.beanToHttpString(groisBean, true, false);
			groisCall.setData(s);
			groisCall.callService();
			Logger.verifyEquals(ECode.SUCCESS, groisCall.getCode(), "验证Code");
			Logger.verifyEquals(0, groisCall.getRelatedOrderInfosResp()
					.getOrderInfoList().size(), "验证orderInfoList 为空");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetRelatedOrderInfos_003() {
		Logger.start(false, "OrderId不存在，获取相关订单详情为空,成功");
		try {
			int orderId = 404;
			groisBean.setOrderId(orderId);
			String s = FormatUtil.beanToHttpString(groisBean, true, false);
			groisCall.setData(s);
			groisCall.callService();
			Logger.verifyEquals(ECode.SUCCESS, groisCall.getCode(), "验证Code");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetRelatedOrderInfos_004() {
		Logger.start(true, "订单包含一个商品, 根据OrderId获取相关订单详情,成功");
		try {
			Logger.comment("准备测试订单数据");
			int sellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
			int userId = Integer.valueOf(EnvSetup.getData("BuyUserId"));
			OrderCreate o = new OrderCreate();
			o.setProductCount(1);
			int orderId = o.create1_M2cOrder(userId, sellerId).getiOrderId();
			Thread.sleep(500l);
			Logger.comment("准备测试订单数据");

			groisBean.setOrderId(orderId);
			String s = FormatUtil.beanToHttpString(groisBean, true, false);
			groisCall.setData(s);
			groisCall.callService();
			Logger.verifyEquals(ECode.SUCCESS, groisCall.getCode(), "验证Code");
			verify();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_GetRelatedOrderInfos_005() {
		Logger.start(true, "sellerquery2冒烟测试");
		try {
			groisBean.setOrderId(112477943);
			String s = FormatUtil.beanToHttpString(groisBean, true, false);
			groisCall.setData(s);
			groisCall.callService();
			Logger.verifyEquals(ECode.SUCCESS, groisCall.getCode(), "验证Code");
			verify();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetRelatedOrderInfos_006() {
		Logger.start(true, "一个主单包含多个子订单,根据其中一个OrderId获取相关订单详情,成功");

		try {

			Logger.comment("准备测试订单数据");

			int orderId = PlaceOrderService.placeOrder3().getOrderList().get(0)
					.getOrderId();

			Logger.comment("准备测试订单数据完成");

			SyncVerifyService.getSyncResult(orderId);

			groisBean.setOrderId(orderId);

			String s = FormatUtil.beanToHttpString(groisBean, true, false);
			groisCall.setData(s);
			groisCall.callService();
			Logger.verifyEquals(ECode.SUCCESS, groisCall.getCode(), "验证Code");

			verify();

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetRelatedOrderInfos_007() {
		Logger.start(true, "一个主单包含2多个买手,根据其中一个OrderId获取相关订单详情,成功");

		try {

			Logger.comment("准备测试订单数据");

			JSONArray orders = (JSONArray) placeOrder3().get("orderId");

			int orderId = orders.getInt(0);

			Logger.comment("准备测试订单数据完成");

			SyncVerifyService.getSyncResult(orderId);

			groisBean.setOrderId(orderId);

			String s = FormatUtil.beanToHttpString(groisBean, true, false);
			groisCall.setData(s);
			groisCall.callService();
			Logger.verifyEquals(ECode.SUCCESS, groisCall.getCode(), "验证Code");

			verify();

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}
